package Biz;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import Entity.PcrTube;

/**
 * Session Bean implementation class updateTubeBean
 */
@Stateless
@LocalBean
public class updateTubeBean implements updateTubeBeanLocal {

    @PersistenceContext(unitName = "PCR_System")
    private EntityManager manager;
    /**
     * Default constructor. 
     */
    public updateTubeBean() {
        // TODO Auto-generated constructor stub
    }
    public void update(String ID,String result)
    {
    	SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
		PcrTube t= manager.find(PcrTube.class, ID);
		if(t!=null)
		{
	    	t.setStatus(result);
	    	t.setId(ID);
	    	t.setResult_time(ft.format(new Date()));
			manager.merge(t);
			manager.flush();
		}
    }
    public void update(String ID,String result,String resultTime)
    {
		PcrTube t= manager.find(PcrTube.class, ID);
		if(t!=null)
		{
	    	t.setStatus(result);
	    	t.setId(ID);
	    	t.setResult_time(resultTime);
			manager.merge(t);
			manager.flush();
		}
    }

}
